document.querySelectorAll('.library-btn').forEach((element, index) => {
    element.addEventListener('click', function () {
        document.querySelectorAll('.library-btn').forEach((e, i) => {
            document.querySelector(`.inner[data-index='${i}']`).style.display = 'none';
        });
        document.querySelector(`.inner[data-index='${index}']`).style.display = 'block';
    })
})

document.querySelector('.main-detail').addEventListener('click', function () {
    if (document.querySelector('.container').style.display === 'block') {
        document.querySelector('.container').style.display = 'none'
    } else {
        document.querySelector('.container').style.display = 'block'
    }
})

if (JSON.parse(localStorage.getItem('login'))) {
    // console.log(1);
    document.querySelector('.header-loginBtn').style.display = 'none'
    document.querySelector('.header-loginUser').innerHTML = JSON.parse(localStorage.getItem('login'))[0].username
    document.querySelector('.username').innerHTML = JSON.parse(localStorage.getItem('login'))[0].username
    JSON.parse(localStorage.getItem('arr')).forEach(element => {
        if (element.username == JSON.parse(localStorage.getItem('login'))[0].username) {
            document.querySelector('.email').innerHTML = element.email
        }
    })

}
const bookCollection = JSON.parse(localStorage.getItem('bookCollection'))
let str1 = ''
if(bookCollection===null){
    shou.innerHTML=''
}else{
    if(bookCollection[0][0]!=undefined){
    bookCollection.forEach((item,index)=>{
        str1+=`
        <div class="like-list">
        <div class="list-info">
            <div class="list-index">${index+1}.</div>
            <div class="list-name">${item[5]}</div>
            <div class="list-type">图书</div>
            <div class="list-unlikebtn">
                <img src="imgas/like.png" alt="">
            </div>
        </div>
        <div class="list-content">
            <div style="display: flex;">
                <img src="imgas/${item[0]}" alt="">
                <div class="content-main">
                    <div class="main-line1">
                        <div class="main-chubanshe">
                            <span>出版社:</span>
                            <span>中国友谊出版公司 / 2020-12</span>
                        </div>
                        <div class="main-num">
                            <span>剩余可借:</span>
                            <span>2</span>
                        </div>
                    </div>
                    <div class="main-line2">
                        <span>内容与摘要附注:</span>
                        <span>123</span>
                    </div>
                    <div class="main-line3">
                        <div class="line3-inline">
                            <div class="main-detail list" data-id="0">详细信息</div>
                            <div class="main-assets list" data-id="1">图书数量(3)</div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="container" style="display: none;">
                <div>
                    <div class="eachDetail">
                        <span class="t1">责任者：</span>
                        <span class="t2">（中国）中共中央文献研究室编编</span>
                    </div>
                    <div class="eachDetail">
                        <span class="t1">版本说明：</span>
                        <span class="t2">一</span>
                    </div>
                    <div class="eachDetail">
                        <span class="t1">出版发行项：</span>
                        <span class="t2">北京:中央文献出版社,1991.7</span>
                    </div>
                    <div class="eachDetail">
                        <span class="t1">ISBN及定价：</span>
                        <span class="t2">7-5073-0073-0 平装/5.8</span>
                    </div>
                    <div class="eachDetail">
                        <span class="t1">载体形态项：</span>
                        <span class="t2">628;32</span>
                    </div>
                    <div class="eachDetail">
                        <span class="t1">并列正题名：</span>
                        <span class="t2"></span>
                    </div>
                    <div class="eachDetail">
                        <span class="t1">丛编项：</span>
                        <span class="t2"></span>
                    </div>
                    <div class="eachDetail">
                        <span class="t1">个人责任者：</span>
                        <span class="t2">中共中央文献研究室编,中国,编</span>
                    </div>
                    <div class="eachDetail">
                        <span class="t1">中图法分类号：</span>
                        <span class="t2">A841</span>
                    </div>
                    <div class="eachDetail">
                        <span class="t1">一般附注：</span>
                        <span class="t2"></span>
                    </div>
                    <div class="eachDetail">
                        <span class="t1">题名责任附注：</span>
                        <span class="t2"></span>
                    </div>
                    <div class="eachDetail">
                        <span class="t1">出版发行附注：</span>
                        <span class="t2"></span>
                    </div>
                    <div class="eachDetail">
                        <span class="t1">主题检索附注：</span>
                        <span class="t2"></span>
                    </div>
                    <div class="eachDetail">
                        <span class="t1">提要文摘附注：</span>
                        <span class="t2"></span>
                    </div>
                </div>
            </div>
        </div>
    </div>
        `
    })}
    shou.innerHTML = str1
}
